import { userService } from "@/api/user"
import { defineStore } from "pinia"
import { ref } from 'vue'
export const userStore = defineStore('User', () => {
  const token = ref('')
  const setToken = (newValue) => {
    token.value = newValue
  }
  const removeToken = () => {
    token.value = ''
  }


  const user = ref({})
  const getUser = async () => {
    const res = await userService()
    console.log(res);
    user.value = res.data.data
    console.log(user.value);
  }
  const setUser = (obj) => {
    user.value = obj
  }
  const removeUser = () => {
    user.value = {}
  }
  return {
    token, setToken, removeToken, user, getUser, removeUser,setUser
  }
}, {
  persist: true
})